package lol.clann.minecraft.springboot.plugin.core.config.jackson.fill;

import relocate.com.fasterxml.jackson.databind.DeserializationContext;
import relocate.com.fasterxml.jackson.databind.deser.ValueInstantiator;

import javax.annotation.Nonnull;
import java.io.IOException;

/**
 * @author pyz
 * @date 2018/10/14 上午12:11
 */
public class ThreadLocalValueInstantiator extends ValueInstantiator {

    private final Object value;

    public ThreadLocalValueInstantiator(@Nonnull Object value) {
        this.value = value;
    }

    @Override
    public boolean canInstantiate() {
        return true;
    }

    @Override
    public boolean canCreateUsingDefault() {
        return true;
    }

    @Override
    public Object createUsingDefault(DeserializationContext ctxt) throws IOException {
        return this.value;
    }

}
